package net.newsmth.smthapp.android.config;

/**
 * Created by Hatsune Miku on 3/26/14.
 *
 */
public enum SmthNetStatusType {
    OK,
    NETWORK_FAILURE,
    SERVER_ERROR,
    TOKEN_FAILURE,
    SIGNATURE_FAILURE,
    SYSTEM_ERROR,
    USERNAME_NOT_FOUND,
    PASSWORD_ERROR,
    OTHERS;


    public static SmthNetStatusType convertFromErrorCode(int errorCode) {
        if (errorCode == 0) {
            return SmthNetStatusType.OK;
        }
        else if (errorCode == -1) {
            return SmthNetStatusType.NETWORK_FAILURE;
        }
        else if (-2 <= errorCode && errorCode <= -10) {
            return  SmthNetStatusType.SERVER_ERROR;
        }
        else if (errorCode == 10010 || errorCode == 10014) {
            return  SmthNetStatusType.TOKEN_FAILURE;
        }
        else if (errorCode == 10004 || errorCode == 10011 || errorCode == 10012 ||
                errorCode == 10013) {
            return SmthNetStatusType.SIGNATURE_FAILURE;
        }
        else if (10000 <= errorCode && errorCode <= 10299)
        {
            return SmthNetStatusType.SYSTEM_ERROR;
        }
        else {
            return  SmthNetStatusType.OTHERS;
        }
    }
}
